//
//  UIView+Extension.swift
//  DanTangSwift
//
//  Created by 众力金融 on 2017/6/21.
//  Copyright © 2017年 ..... All rights reserved.
//

import UIKit

extension UIView {
    /** origin的X */
    var x: CGFloat {
        get {
            return frame.origin.x
        }
        set {
            var temFrame : CGRect = frame
             temFrame.origin.x    = newValue
             frame = temFrame
        }
    }
    
     /** origin的Y */
    var y: CGFloat {
        get {
            return frame.origin.y
        }
        set {
            var temFrame : CGRect = frame
            temFrame.origin.y = newValue
            frame = temFrame
        }
    }
    
    /** 控件的宽度 */
    var width: CGFloat {
        get {
            return frame.size.width
        }
        set {
            var tmpFrame : CGRect = frame
            tmpFrame.size.width   = newValue
            frame                 = tmpFrame
        }
    }
    
    /** 控件的高度 */
    var height: CGFloat {
        get {
            return frame.size.height
        }
        set {
            var tmpFrame : CGRect = frame
            tmpFrame.size.height  = newValue
            frame                 = tmpFrame
        }
    }
    
    /** size */
    var size: CGSize {
        get {
            return frame.size
        }
        set(newValue) {
            var tempFrame: CGRect = frame
            tempFrame.size = newValue
            frame = tempFrame
        }
    }
    
    /** centerX */
    var centerX: CGFloat {
        get {
            return center.x
        }
        set(newValue) {
            var tempCenter: CGPoint = center
            tempCenter.x = newValue
            center = tempCenter
        }
    }
    
    /** centerY */
    var centerY: CGFloat {
        get {
            return center.y
        }
        set(newValue) {
            var tempCenter: CGPoint = center
            tempCenter.y = newValue
            center = tempCenter;
        }
    }

    
}
